home *** CD-ROM | disk | FTP | other *** search
/ Celestin Apprentice 2 / Apprentice-Release2.iso / Tools / Languages / Caml Light 0.61 / Source / src / compiler / main.ml < prev    next >
Encoding:
Text File  |  1993-09-24  |  1.8 KB  |  61 lines  |  [TEXT/MPS ]

  1. (* The Caml Light compiler. Command-line parsing. *)
  2.  
  3. #open "config";;
  4. #open "misc";;
  5. #open "modules";;
  6. #open "compiler";;
  7.  
  8. let anonymous s =
  9.   if filename__check_suffix s ".ml" then
  10.     let filename = filename__chop_suffix s ".ml" in
  11.     compile_implementation (filename__basename filename) filename
  12.   else if filename__check_suffix s ".mli" then
  13.     let filename = filename__chop_suffix s ".mli" in
  14.     compile_interface (filename__basename filename) filename
  15.   else
  16.     raise (arg__Bad ("don't know what to do with " ^ s))
  17. and set_stdlib p =
  18.   path_library := p;
  19.   load_path := [!path_library]
  20. and add_include d =
  21.   load_path := d :: !load_path
  22. and open_set set =
  23.   try
  24.     default_used_modules := assoc set default_used_interfaces
  25.   with Not_found ->
  26.     raise (arg__Bad ("unknown module set " ^ set))
  27. and show_version () =
  28.    prerr_string version__banner; prerr_endline ""
  29. and show_types_flag () =
  30.   compiler__verbose := true
  31. and debug_option () =
  32.   compiler__write_extended_zi := true
  33. ;;
  34.  
  35. let main() =
  36. try
  37.   sys__catch_break true;
  38.   default_used_modules := assoc "cautious" default_used_interfaces;
  39.   load_path := [!path_library];
  40.   arg__parse ["-stdlib", arg__String set_stdlib;
  41.               "-I", arg__String add_include;
  42.               "-include", arg__String add_include;
  43.               "-O", arg__String open_set;
  44.               "-open", arg__String open_set;
  45.               "-v", arg__Unit show_version;
  46.               "-version", arg__Unit show_version;
  47.               "-i", arg__Unit show_types_flag;
  48.               "-g", arg__Unit debug_option;
  49.               "-debug", arg__Unit debug_option;
  50.               "-", arg__String anonymous]
  51.              anonymous;
  52.   exit 0
  53.  
  54. with Toplevel -> exit 2
  55.    | sys__Break -> exit 3
  56.    | Zinc s -> prerr_string "# Internal error: "; prerr_endline s; exit 4
  57. ;;
  58.  
  59. printexc__f main ()
  60. ;;
  61.